<template>
    <el-select :value="value" :source="source" clearable :placeholder="placeholder" style="width:100%"
        @input="sendChange">
        <el-option v-for="item in Options" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
    </el-select>
</template>
<script>
    import * as dictService from '@/api/bdms/dict'

    import * as filespaceService from '@/api/file/filespace'

    import * as areaService from '@/api/bdms/area'

    import * as userService from '@/api/upms/user'

    export default {
        props: {
            value: {
                type: String,
                default: ""
            },
            source: {
                type: String,
                default: ""
            },
            dictType: {
                type: String,
                default: ""
            },
            placeholder: {
                type: String,
                default: "请选择"
            }
        },
        data() {
            return {
                Options: []
            }
        },
        components: {},
        created() {
            this.getDict()
        },
        methods: {
            getDict() {
                // 文件空间
                if (this.source == 'fileSpace') {
                    filespaceService.getfilespacedict(null).then(data => {
                        this.Options = data;
                    })
                }
                // 国家字典
                if (this.source == 'country') {
                    areaService.getAreaCountryDict().then(data => {
                        this.Options = data;
                    })
                }
                // 省市字典
                if (this.source == 'city') {
                    areaService.getAreaCityDict().then(data => {
                        this.Options = data;
                    })
                }
                // 管理员列表
                if(this.source == 'admin'){
                    userService.getadminuser().then(data => {
                        this.Options = data;
                    })
                }
                // 业务用户列表
                if(this.source == 'business'){
                    userService.getbususer().then(data => {
                        this.Options = data;
                    })
                }
            },
            sendChange(currentValue) {
                this.$emit("input", currentValue);
            }
        }
    }
</script>